package com.bite.demo.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Slf4j
@Aspect
//@Component
public class AspectDemo {
    @Pointcut("execution(* com.bite.demo.controller.*.*(..))")
    public void pt(){
    }
    @Before("pt()")
    public void doBefore(){
        log.info("执行AspectDemo before...");
    }

    @After("pt()")
    public void doAfter(){
        log.info("执行AspectDemo doAfter...");
    }
    @AfterReturning("pt()")
    public void doAfterReturning(){
        log.info("执行AspectDemo doAfterReturning...");
    }
    @AfterThrowing("execution(* com.bite.demo.controller.*.*(..))")
    public void doAfterThrowing(){
        log.info("执行AspectDemo doAfterThrowing...");
    }
    @Around("execution(* com.bite.demo.controller.*.*(..))")
    public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
        log.info("执行AspectDemo doAround 前...");
        Object result = joinPoint.proceed();
        log.info("执行AspectDemo doAround 后...");
        return result;
    }
}
